home *** CD-ROM | disk | FTP | other *** search
- *==========================================================================*
- * ReverseList.asm -- Reverses the order of a singly-linked list *
- * By Talin. (c) 1990 Sylvan Technical Arts. *
- *==========================================================================*
-
- xdef _HashVal
- xdef _CmpMemI
-
- _HashVal: ; (name:a0, length:d0, hashsize:d1)
- movem.l d2/d3,-(sp)
- moveq #0,d3 ; clear initial hash value
- moveq #0,d2 ; clear upper half of character value
- bra.s 2$
- 1$ move.b (a0)+,d2 ; next byte of string
- and.b #%11011111,d2 ; munge byte so upper case == lower.
- mulu #13,d3 ; multiply hash *13.
- add.l d2,d3 ; add new byte to hashval.
- 2$ dbra d0,1$ ; loop until done
- swap d3 ; clear upper half d3
- clr.w d3 ; to avoid divide overflow
- swap d3
- divu.w d1,d3 ; divide by hash table size.
- clr.w d3 ; get rid of quotient
- swap d3 ; get just remainder
- move.l d3,d0 ; return hash value
- movem.l (sp)+,d2/d3
- rts
-
-
- ; IMATCH - a macro that quickly does a case-insensitive character test
- ; Note this function destroys the two registers passed to it.
- ; Usage:
- ; IMATCH reg1,reg1,matchlabel,nomatchmabel
-
- IMATCH macro
-
- cmp.b \1,\2 ; if characters match
- beq.s \3
- eor.b \1,\2 ; get exclusive or of characters
- cmp.b #32,\2 ; if different only by bit 32
- bne.s \4 ; then
- bset #5,\1 ; force to upper case
- cmp.b #$61,\1 ; if less than lower case 'a'
- blo.s \4 ; then no match
- cmp.b #$7a,\1 ; if less that or equal to lower 'z'
- bls.s \3 ; then match
- cmp.b #$E0,\1 ; if less than lower case 'à'
- blo.s \4 ; then no match
- bra.s \3 ; then match
-
- endm
-
- _CmpMemI
- move.l 4(sp),a0
- move.l 8(sp),a1
- move.l 12(sp),d1
- move.l d2,-(sp)
- bra.s 3$
-
- 2$ move.b (a1)+,d0 ; are current bytes different?
- move.b (a0)+,d2
-
- IMATCH d0,d2,3$,1$
-
- 3$ dbra d1,2$
-
- moveq #1,d0
- move.l (sp)+,d2
- rts
-
- 1$ moveq #0,d0
- move.l (sp)+,d2
- rts
-
- end
-